package com.ziyear.servlet;

import com.ziyear.domain.Train;
import com.ziyear.service.PrepService;
import com.ziyear.service.TrainService;
import com.ziyear.service.impl.PrepServiceImpl;
import com.ziyear.service.impl.TrainServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


/**
 * 功能描述 : 删除订单
 *
 * @author Ziyear
 */
public class DeletePrepServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;


    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Integer prepId = Integer.valueOf(request.getParameter("prepId"));

        PrepService prepService = new PrepServiceImpl();
        boolean refund = prepService.refund(prepId);

        PrintWriter out = response.getWriter();
        if (refund) {
            out.write("<script>alert('退票成功！');" + "window.location.href='MyPrepServlet'</script>");
        } else {
            out.write("<script>alert('很抱歉,退票失败！');" + "window.location.href='MyPrepServlet'</script>");
        }

        out.close();
    }

}
